import java.util.Random;

public class 冒泡排序 {

    private static void sort(int[] ints) {
        int len = ints.length;
        for (int i = 0; i < len - 1; i++) {
            for (int j = i + 1; j < len; j++) {
                ints[j] = ints[i] > ints[j] ? ints[i] + ints[j] - (ints[i] = ints[j]) : ints[j];
            }
        }
    }

    private static final int N = 100000;
    public static void main(String[] args) {
        int[] ints = new int[N];
        int len = ints.length;
        Random random = new Random();
        for (int i = 0; i < len; i++) {
            ints[i] = random.nextInt(N);
        }
        Long start = System.currentTimeMillis();
        sort(ints);
        Long end = System.currentTimeMillis();
        StringBuilder sb = new StringBuilder("");
        for (int i : ints) {
            sb.append(i).append(", ");
        }
        System.out.println((end - start) + " ms\n[" + sb.delete(sb.length() - 2, sb.length()) + "]");
    }
}
